home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
MATH
/
LGSOLV1.ZIP
/
DEMOTEST.FOR
< prev
next >
Wrap
Text File
|
1992-12-01
|
9KB
|
287 lines
INCLUDE 'FGRAPH.FI'
program demotest
C 1. Objects for LGSOLV :
PARAMETER(MAXBUF=8005)
PARAMETER(MAXDIM=1000)
common/buf1/b1(MAXBUF)
common/buf2/b2(MAXBUF)
real*8 b1,b2,g1sol,g1emat,g1fmat,g1rp
external elmatr,elvect
real*8 elmatr,elvect
C 2. Objects for Screen Output and Random Generator :
INCLUDE 'FGRAPH.FD'
RECORD / rccoord / curpos
COMMON /grand/ rand,rseed
INTEGER*2 dummy2,rseed
INTEGER*4 dummy4
REAL*4 rand
C
C 3. Objects for Demo Test :
common /btest/ mt,nex,t1,umm(5,5),v(maxdim)
real*8 v,umm,x,s1,s2,s11,s12
CHARACTER*36 str
character*30 diagn(4)
INTEGER*2 th,tm,ts
integer*4 t1,t2,lb,lw,n,nc
data lb/1000/, lw/8/, n/10/, nc/1/, last/0/
data umm/ 1.0, 1.0, 0.0, 0.0, 0.0,
* 2.0, 2.0, 0.0, 0.0, 0.0,
* 1.0, 0.0, 3.0, 0.0, 0.0,
* 0.0, 0.0, 0.0, 1.0, 0.0,
* 0.0, 0.0, 0.0, 0.0, 0.0 /
data diagn/30HSingular matrix !!! ,
* 30HSystem buffers are too small ! ,
* 30HInsufficient disk-space !!! ,
* 30H /
C
mt=2
1 dummy4 = setbkcolor( 7 )
dummy2 = settextcolor( 15 )
CALL clearscreen( $GCLEARSCREEN )
CALL settextposition( 1,20,curpos )
CALL outtext( 'LGSOLV Demo Test.' )
dummy2 = settextcolor( 0 )
12 lb=inpnum(4,40,'Buffer Size : ',2,maxbuf,lb)
n =inpnum(5,40,'System Dimension : ',2,maxdim,n)
CALL settextposition( 7,40,curpos )
call outtext( ' ( -1 means Matrix Inversion ! )')
nc=inpnum(6,40,'Number of Right Parts : ',-1,maxdim,nc)
CALL settextposition( 6,2,curpos )
CALL settextposition( 8,40,curpos )
call outtext( ' ( 4 or 8 bytes per word ) ')
lw=inpnum(7,40,'Matrix packing factor : ',4,8,lw)
CALL settextposition( 9,40,curpos )
call outtext( ' ( 1-E, 2-Random, 3-Singular )')
j=3
if(n.le.5) j=4
mt=inpnum(8,40,'Matrix type for test : ',1,j,mt)
C
C .... Random Generator Initialize
call gettim(th,tm,ts,rseed)
t1=3600*th+60*tm+ts
rseed=int2(100*t1+rseed)
call seed(rseed)
nex=0
i=10*n+mt-last
if(i.ne.0.or.nc.lt.0) goto 122
call settextposition(12,22,curpos)
call outtext('Matrix was given and factorized last time !')
goto 123
122 dummy4 = setbkcolor( 3 )
dummy2 = settextcolor( 15 )
call settextposition(13,20,curpos)
str(1:1)='P'
if(nc.lt.0) str(1:1)='V'
call outtext(' mer = LGMIN'//str(1:1)//'(')
call outnum(lb)
call outtext(',')
call outnum(lw)
call outtext(',')
call outnum(n)
call outtext(',elmfun) ')
dummy4 = setbkcolor( 7 )
dummy2 = settextcolor( 0 )
if(nc.gt.0) nerror=lgminp( lb, lw, n, elmatr )
if(nc.le.0) nerror=lgminv( lb, lw, n, elmatr )
if(nerror.ne.0.or.nc.le.0) goto 2
123 dummy4 = setbkcolor( 3 )
dummy2 = settextcolor( 15 )
call settextposition(13,20,curpos)
call outtext(' mer = LGSOLV(')
call outnum(nc)
call outtext(',rpsfun) ')
dummy4 = setbkcolor( 7 )
dummy2 = settextcolor( 0 )
nerror=lgsolv(nc,elvect)
C
2 call gettim(th,tm,ts,dummy2)
t2=3600*th+60*tm+ts
last=0
CALL settextposition( 9,2, curpos )
if(nerror.ne.0) call outtext('Error code='//
* char(nerror+48)//' : '//diagn(nerror))
if(nerror.ne.0) goto 9
call vist('Results reading and checking ... ')
s11=0.0D0
s12=0.0D0
ncc=iabs(nc)
dummy4 = setbkcolor( 3 )
dummy2 = settextcolor( 15 )
call settextposition(13,20,curpos)
if(nc.gt.0) call outtext(' x = G1SOL(i,j) ')
if(nc.lt.0) call outtext(' x = G1EMAT(i,j) ')
dummy4 = setbkcolor( 7 )
dummy2 = settextcolor( 0 )
do 5 j=1,ncc
s1=0.0D0
s2=0.0D0
if(nc.gt.0) then
do 6 i=1,n
x=g1sol(i,j)-dble(i*j)
if(DABS(x).gt.s1) s1=DABS(x)
6 s2=s2+x*x
else
call seed(rseed)
x=0.0D0
do 7 i=1,n
7 x=x+g1emat(1,i)*elmatr(i,1)
if(j.eq.1) x=x-1.0D0
s1=DABS(x)
s2=x*x
endif
if(s2.gt.s12) s12=s2
if(s1.gt.s11) s11=s1
write(str,'(2d7.2)') s11,s12
CALL settextposition( 7,2, curpos )
call outtext('Max Mod Error : '//str(1:7)//char(0))
CALL settextposition( 8,2, curpos )
call outtext('Summ Err**2 : '//str(8:14)//char(0))
5 continue
if(nc.gt.0) last=10*n+mt
9 CALL settextposition( 10,2, curpos )
dummy2 = settextcolor( 0 )
call outtext('Quit (Y/N) : ')
read(*,'(a1)') str(1:1)
if(str(1:1).ne.'Y'.and.str(1:1).ne.'y') goto 1
end
integer function inpnum(nr,nc,title,min,max,ndef)
character*(*) title
INCLUDE 'FGRAPH.FD'
RECORD / rccoord / curpos,cp1
character*6 str
numb=0
1 call settextposition(nr,nc,curpos)
call outtext( title )
write(str,'(i6)') ndef
call outtext(str//' ')
call gettextposition(cp1)
read(*,'(i6)') numb
if(numb.eq.0) numb=ndef
call settextposition(cp1.row,cp1.col,curpos)
call outtext(' ')
if(numb.lt.min.or.numb.gt.max) goto 1
call settextposition(nr,nc,curpos)
call outtext( title )
write(str,'(i6)') numb
call outtext(str)
inpnum=numb
return
end
subroutine outnum(n)
character*12 s
write(s,'(i12)') n
do 1 j=1,12
i=j
if(s(i:i).ne.' ') goto 2
1 continue
2 call outtext(s(i:12))
return
end
subroutine vis0(m1,m2,job)
INCLUDE 'FGRAPH.FD'
RECORD / rccoord / curpos,cp1
integer*2 d,m1,m2,th,tm,ts
character*(*) title
real*8 price
common /btest/ mt,nex,nt1
character*6 kb
character*50 s,bs
SAVE
data s/'██████████████████████████████████████████████████'/
data bs/' '/
call gettextposition(cp1)
if(m1.gt.0) max1=m1
if(m2.gt.0) max2=m2
price=50.0D0 / DBLE(max2)
i4 = setbkcolor( 7 )
d = settextcolor( 15 )
CALL settextposition( 18,2,curpos )
CALL outtext( 'Disk Exchange Diagramm : ' )
d = settextcolor( 0 )
CALL settextposition( 20,2,curpos )
call outtext('Input matrix: '//s)
CALL settextposition( 22,2,curpos )
call outtext('Factor-matrix: '//s)
CALL settextposition( 24,2,curpos )
call outtext('matrix')
if(max1.lt.max2) call outtext('+right parts')
call outtext('=')
call outnum(max2)
call outtext(' bl.')
k=int(price)
if(k.eq.0) k=1
call outtext(' 1 block')
if(max2.gt.2) call outtext(' '//s(1:k))
call outtext(' = ')
call outnum(job)
call outtext(' bytes.')
d = settextcolor( 4 )
call outtext(' '//s(1:1)//'-Write,')
d = settextcolor( 1 )
call outtext(' '//s(1:1)//'-Read.')
d = settextcolor( 0 )
goto 100
entry vist(title)
call gettextposition(cp1)
CALL settextposition( 18,28,curpos )
d = settextcolor( 0 )
call outtext(title)
goto 200
entry vis(m1,m2,job)
nex=nex+1
npos=18+2*m1
call gettextposition(cp1)
k=4
if(job.ne.0) k=1
d=settextcolor(k)
k1=int( price*DBLE(m2-1) )
call settextposition(npos,20+k1,curpos)
k=1+int( price*DBLE(m2) )
if(k.gt.50) k=50
call outtext(s(k1+1:k))
d=settextcolor(0)
call settextposition(npos+1,21,curpos)
bs(k1:k1)=''
call outtext(bs)
bs(k1:k1)=' '
200 call gettim(th,tm,ts,d)
nt2=3600*th+60*tm+ts
CALL settextposition( 5,2,curpos )
call outtext('Number of exchanges: ')
call outnum(nex)
call settextposition( 4,2,curpos)
call outtext('Elapsed Time (sec) : ')
call outnum(nt2-nt1)
100 call settextposition(cp1.row,cp1.col,curpos)
return
end
real*8 function elmatr(i,j)
integer*2 i,j
common /grand/ r
REAL*4 r
common /btest/ mt,nex,nt1,umm(5,5),v(2)
real*8 v,umm,elvect
elmatr=0.0D0
if(i.eq.j) elmatr=1.0D0
if(mt.eq.1) goto 1
CALL RANDOM(r)
elmatr=1.0D1*(0.5D0-DBLE(r))
if(mt.eq.2) goto 1
if(j.eq.2) elmatr=v(i)*3.0D0
if(mt.eq.4) elmatr=umm(i,j)
1 if(j.eq.1) v(i)=elmatr
if(j.ne.1) v(i)=v(i)+elmatr*DBLE(j)
return
entry elvect(i,j)
elvect=v(i)*DBLE(j)
return
end